package com.fr.chart.axis;

import com.fr.base.core.json.JSONException;
import com.fr.base.core.json.JSONObject;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;

public class CategoryAxis extends Axis
{
  private static final long serialVersionUID = 1L;
  public static final String XML_TAG = "CategoryAxis";
  public static final int DAY = 1;
  public static final int MONTH = 2;
  public static final int YEAR = 3;
  private boolean isCustomCrement;
  private int crementType = 1;
  private boolean isCustomMainDate;
  private int mainDate;
  private int mainType = 1;
  private boolean isCustomSecondDate;
  private int secondDate;
  private int secondType = 1;
  private boolean isDateAxis = false;

  public void setCustomMainDate(boolean paramBoolean)
  {
    this.isCustomMainDate = paramBoolean;
  }

  public boolean isCustomMainDate()
  {
    return this.isCustomMainDate;
  }

  public void setMainDate(int paramInt)
  {
    this.mainDate = paramInt;
  }

  public int getMainDate()
  {
    return this.mainDate;
  }

  public void setMainType(int paramInt)
  {
    this.mainType = paramInt;
  }

  public int getMainType()
  {
    return this.mainType;
  }

  public void setCustomSecondDate(boolean paramBoolean)
  {
    this.isCustomSecondDate = paramBoolean;
  }

  public boolean isCustomSecondDate()
  {
    return this.isCustomSecondDate;
  }

  public void setSecondDate(int paramInt)
  {
    this.secondDate = paramInt;
  }

  public int getSecondDate()
  {
    return this.secondDate;
  }

  public void setSecondType(int paramInt)
  {
    this.secondType = paramInt;
  }

  public int getSecondType()
  {
    return this.secondType;
  }

  public void setCustomCrement(boolean paramBoolean)
  {
    this.isCustomCrement = paramBoolean;
  }

  public boolean isCustomCrement()
  {
    return this.isCustomCrement;
  }

  public void setCrementType(int paramInt)
  {
    this.crementType = paramInt;
  }

  public int getCrementType()
  {
    return this.crementType;
  }

  public void setDateAxis(boolean paramBoolean)
  {
    this.isDateAxis = paramBoolean;
  }

  public boolean isDateAxis()
  {
    return this.isDateAxis;
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    super.readXML(paramXMLableReader);
    if (paramXMLableReader.isChildNode())
    {
      String str2 = paramXMLableReader.getTagName();
      if (str2.equals("DateAxisAttr"))
      {
        String str1;
        this.isDateAxis = true;
        if ((str1 = paramXMLableReader.getAttr("isCustomMinValue")) != null)
          setCustomMinValue(Boolean.valueOf(str1).booleanValue());
        if ((str1 = paramXMLableReader.getAttr("minValue")) != null)
          setMinValue(Double.valueOf(str1).doubleValue());
        if ((str1 = paramXMLableReader.getAttr("isCustomMaxValue")) != null)
          setCustomMaxValue(Boolean.valueOf(str1).booleanValue());
        if ((str1 = paramXMLableReader.getAttr("maxValue")) != null)
          setMaxValue(Double.valueOf(str1).doubleValue());
        if ((str1 = paramXMLableReader.getAttr("isCustomCrement")) != null)
          this.isCustomCrement = Boolean.valueOf(str1).booleanValue();
        if ((str1 = paramXMLableReader.getAttr("crementType")) != null)
          this.crementType = Integer.valueOf(str1).intValue();
        if ((str1 = paramXMLableReader.getAttr("isCustomMainDate")) != null)
          this.isCustomMainDate = Boolean.valueOf(str1).booleanValue();
        if ((str1 = paramXMLableReader.getAttr("mainDate")) != null)
          this.mainDate = Integer.valueOf(str1).intValue();
        if ((str1 = paramXMLableReader.getAttr("mainType")) != null)
          this.mainType = Integer.valueOf(str1).intValue();
        if ((str1 = paramXMLableReader.getAttr("isCustomSecondDate")) != null)
          this.isCustomSecondDate = Boolean.valueOf(str1).booleanValue();
        if ((str1 = paramXMLableReader.getAttr("secondDate")) != null)
          this.secondDate = Integer.valueOf(str1).intValue();
        if ((str1 = paramXMLableReader.getAttr("secondType")) != null)
          this.secondType = Integer.valueOf(str1).intValue();
      }
    }
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    if (isDateAxis())
      paramXMLPrintWriter.startTAG("DateAxis").attr("class", getClass().getName());
    else
      paramXMLPrintWriter.startTAG("CategoryAxis").attr("class", getClass().getName());
    super.writeXML(paramXMLPrintWriter);
    if (isDateAxis())
      paramXMLPrintWriter.startTAG("DateAxisAttr").attr("isCustomCrement", this.isCustomCrement).attr("crementType", this.crementType).attr("isCustomMainDate", this.isCustomMainDate).attr("mainDate", this.mainDate).attr("mainType", this.mainType).attr("isCustomSecondDate", this.isCustomSecondDate).attr("secondDate", this.secondDate).attr("secondType", this.secondType).end();
    paramXMLPrintWriter.end();
  }

  public boolean equals(Object paramObject)
  {
    if (!(paramObject instanceof CategoryAxis))
      return false;
    CategoryAxis localCategoryAxis = (CategoryAxis)paramObject;
    if (!(super.equals(localCategoryAxis)))
      return false;
    return ((localCategoryAxis.isCustomCrement == this.isCustomCrement) && (localCategoryAxis.crementType == this.crementType) && (localCategoryAxis.isCustomMainDate == this.isCustomMainDate) && (localCategoryAxis.mainDate == this.mainDate) && (localCategoryAxis.mainType == this.mainType) && (localCategoryAxis.isCustomSecondDate == this.isCustomSecondDate) && (localCategoryAxis.secondDate == this.secondDate) && (localCategoryAxis.secondType == this.secondType) && (localCategoryAxis.isDateAxis == this.isDateAxis));
  }

  public JSONObject toJSONObject()
    throws JSONException
  {
    JSONObject localJSONObject = super.toJSONObject();
    if (isDateAxis())
    {
      localJSONObject.put("isCustomCrement", this.isCustomCrement);
      localJSONObject.put("crementType", this.crementType);
      localJSONObject.put("isCustomMainDate", this.isCustomMainDate);
      localJSONObject.put("mainDate", this.mainDate);
      localJSONObject.put("mainType", this.mainType);
      localJSONObject.put("isCustomSecondDate", this.isCustomSecondDate);
      localJSONObject.put("secondDate", this.secondDate);
      localJSONObject.put("secondType", this.secondType);
      localJSONObject.put("isDateAxis", this.isDateAxis);
    }
    return localJSONObject;
  }
}